package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.purchase.RCPurchaseOrderAccept;
import com.shrct.businessprocess.purchase.RCPurchaseOrderAcceptItem;
import com.shrct.businessprocess.purchase.RCPurchaseOrderItem;
import com.shrct.businessprocess.purchase.impl.RCPurchaseOrderAcceptImpl;
import com.shrct.businessprocess.purchase.impl.RCPurchaseOrderItemImpl;
import com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderAcceptItemProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPURCHASEORDERACCEPTITEM_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcpurchaseorderacceptitem")
public class RCPurchaseOrderAcceptItemImpl extends BaseModelObject implements RCPurchaseOrderAcceptItem {
  public RCPurchaseOrderAcceptItemImpl() {
    super();
  }
  
  public RCPurchaseOrderAcceptItemImpl(final RCPurchaseOrderAccept accept) {
    super();
    this.accept = accept;
  }
  
  @JoinColumn(name = "accept_id")
  @ManyToOne(targetEntity = RCPurchaseOrderAcceptImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCPurchaseOrderAccept accept;
  
  public RCPurchaseOrderAccept getAccept() {
    return this.accept;
  }
  
  public RCPurchaseOrderAcceptItem setAccept(final RCPurchaseOrderAccept accept) {
    this.accept = accept;
    return this;			
    
  }
  
  @JoinColumn(name = "orderItem_id")
  @ManyToOne(targetEntity = RCPurchaseOrderItemImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCPurchaseOrderItem orderItem;
  
  public RCPurchaseOrderItem getOrderItem() {
    return this.orderItem;
  }
  
  public RCPurchaseOrderAcceptItem setOrderItem(final RCPurchaseOrderItem orderItem) {
    this.orderItem = orderItem;
    return this;			
    
  }
  
  private Integer quantity;
  
  public Integer getQuantity() {
    return this.quantity;
  }
  
  public RCPurchaseOrderAcceptItem setQuantity(final Integer quantity) {
    this.quantity = quantity;
    return this;			
    
  }
  
  public static RCPurchaseOrderAcceptItem create(final RCPurchaseOrderAccept accept, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCPurchaseOrderAcceptItem rCPurchaseOrderAcceptItem = new com.shrct.businessprocess.purchase.impl.RCPurchaseOrderAcceptItemImpl(
    	accept
    );
    objectFactory.create(rCPurchaseOrderAcceptItem);
    return rCPurchaseOrderAcceptItem;			
    
  }
  
  public static RCPurchaseOrderAcceptItem createRCPurchaseOrderAcceptItemImpl(final RCPurchaseOrderAccept accept, final IObjectFactory objectFactory, final Procedure1<RCPurchaseOrderAcceptItem> init) {
    com.shrct.businessprocess.purchase.RCPurchaseOrderAcceptItem rCPurchaseOrderAcceptItem = new com.shrct.businessprocess.purchase.impl.RCPurchaseOrderAcceptItemImpl(
    	accept
    );
    objectFactory.create(rCPurchaseOrderAcceptItem);
    init.apply(rCPurchaseOrderAcceptItem);
    
    return rCPurchaseOrderAcceptItem;			
    
  }
  
  public RCPurchaseOrderAcceptItemProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderAcceptItemProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderAcceptItemProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
